package com.example.kotlinstudy.类与对象

import android.icu.text.Transliterator.Position

interface MyInterface {
    val prop: Int
    val propertyWithImplementation: String
        get() = "foo"

    fun bar()
    fun foo() {
        print(prop)
    }
}

class Child : MyInterface {
    override val prop: Int
        get() = 29

    override fun bar() {

    }
}

///接口继承
interface Named {
    val name: String
}

interface PersonA : Named {
    val firstName: String
    val lastName: String
    override val name: String
        get() = "$firstName $lastName"
}

data class Employee(
    override val firstName: String,
    override val lastName: String,
    val position: Position,
) : PersonA

///解决覆盖冲突
interface A {
    fun foo() {
        print("A")
    }
    fun bar()
}
interface B {
    fun foo() {
        print("B")
    }
    fun bar() {
        print("bar")
    }
}
class C : A {
    override fun bar() {
        print("bar")
    }
}
class D : A, B {
    override fun foo() {
        super<A>.foo()
        super<B>.foo()
    }

    override fun bar() {
        super<B>.bar()
    }
}